package com.slipper.qmt.task;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;

public class TaskList {
    private final AtomicInteger totalSize = new AtomicInteger(0);
    private final BlockingQueue<Object> queue = new LinkedBlockingQueue<>();

    public void product(Object data) throws InterruptedException {
        queue.put(data);
        totalSize.incrementAndGet();
    }

    public Object consume() throws InterruptedException {
        return queue.take();
    }

    public void clear() {
        queue.clear();
    }

    public int getTotalSize() {
        return totalSize.get();
    }

    public int getCurrSize() {
        return queue.size();
    }
}
